home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / A / AE Sample (TC5) / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-07  |  2.2 KB  |  118 lines  |  [TEXT/KAHL]

  1. /* File: main.c */
  2.  
  3. #define        __Main__
  4. #include    "AESimple.h"
  5.  
  6. void DoKey (EventRecord *theEvent)
  7. {
  8.     char        keyPressed = (theEvent->message & charCodeMask);
  9.  
  10.     if (theEvent->modifiers & cmdKey) {
  11.             AdjustMenus();
  12.             Dispatch(MenuKey(keyPressed));        /*Command key down*/
  13.     }
  14. } /* DoKey */
  15.  
  16.  
  17.  
  18.  
  19. void DoMouseDown (EventRecord *theEvent)
  20. {
  21.     Point        globalPt = theEvent->where;
  22.     short        windowPart;
  23.     WindowPtr    whichWindow;
  24.     Rect        dragRect;
  25.  
  26.     windowPart = FindWindow(globalPt, &whichWindow);
  27.     switch (windowPart) {
  28.         case inMenuBar: 
  29.             AdjustMenus();
  30.             Dispatch(MenuSelect(globalPt));
  31.             break;
  32.  
  33.         case inSysWindow: 
  34.             SystemClick(theEvent, whichWindow);
  35.             break;
  36.  
  37.  
  38.         case inGoAway: 
  39.             if (TrackGoAway(whichWindow, theEvent->where))
  40.                 CloseAWindow(whichWindow);
  41.             break;
  42.  
  43.         case inDrag: 
  44.             dragRect = screenBits.bounds;
  45.             dragRect.top = 40;
  46.             DragWindow(whichWindow, theEvent->where, &dragRect);
  47.             break;
  48.  
  49.         case inGrow: 
  50.             DoGrowWindow(whichWindow, theEvent);
  51.  
  52.         case inContent: 
  53.                 DoContentClick(whichWindow, globalPt);
  54.             break;
  55.  
  56.         case inZoomIn:
  57.         case inZoomOut: 
  58.             if (TrackBox(whichWindow, globalPt, windowPart)) {
  59.                 SetPort(whichWindow);
  60.                 ZoomWindow(whichWindow, windowPart, TRUE);
  61.             } break;
  62.     }
  63. } /* DoMouseDown */
  64.  
  65.  
  66. void MainLoop()
  67. {
  68.     EventRecord    theEvent;
  69.     DialogPtr    whichDialog;
  70.     short        itemHit;
  71.  
  72.     while (!gDone) {
  73.         WaitNextEvent(everyEvent, &theEvent, 120L, NIL);        
  74.         switch (theEvent.what) {
  75.             case nullEvent:
  76.                 InitCursor();
  77.             break;
  78.  
  79.             case mouseDown: 
  80.                 DoMouseDown(&theEvent);
  81.             break;
  82.  
  83.             case keyDown:
  84.             case autoKey: 
  85.                 DoKey(&theEvent);
  86.             break;
  87.  
  88.             case activateEvt: 
  89.                 DoActivate(&theEvent);
  90.             break;
  91.  
  92.             case updateEvt:
  93.                 DoUpdate((WindowPtr)theEvent.message);
  94.             break;
  95.             
  96.             case app4Evt:
  97.             break;
  98.             
  99.             case kHighLevelEvent:
  100.                 (void)AEProcessAppleEvent(&theEvent);
  101.         }
  102.     }
  103. } /* MainEventLoop */
  104.  
  105.  
  106. void main()
  107. {
  108.     MaxApplZone();
  109.     MoreMasters();               /* create more master pointers    */
  110.     MoreMasters();               /* create more master pointers    */
  111.     MoreMasters();               /* create more master pointers    */
  112.     MoreMasters();               /* create more master pointers    */
  113.     
  114.     Init_all();                    /* call initialization routine    */
  115.     UnloadSeg((ProcPtr)Init_all);       /* make segment purgable    */
  116.     AdjustMenus();
  117.     MainLoop();
  118. }